// 动态类型
// generics
/* function numGen(a: number, b: number):Array<number> {
  return [a, b]
}

function strGen(a: string, b: string): Array<string> {
  return [a, b]
} */
function typeGen(a, b) {
    return [a, b];
}
// number
typeGen(1, 2);
// string
typeGen("1", "2");
let aGenNum = 1;
let aGenStr = "1";
let aGenBoolean = false;
let dataGen = {
    // msg: 1
    msg: "1"
};
/* function addGen<T, K>(a:T, b:K):Array<T | K> {
  return [a, b]
} */
function addGen(a, b) {
    return [a, b];
}
addGen(1, 2);
addGen(1, false);
// addGen()
const axios = {
    get(url) {
        return new Promise((reslove, reject) => {
            let xhr = new XMLHttpRequest();
            xhr.open("GET", url);
            xhr.onreadystatechange = () => {
                if (xhr.readyState === 4 && xhr.status === 200) {
                    reslove(JSON.parse(xhr.responseText));
                }
            };
            xhr.send(null);
        });
    }
};
axios.get("./data.json").then(res => {
    console.log(res.code);
    console.log(res.msg);
});
/*
因为node环境没有xhr
所以只执行：tsc 编译下文件即可
然后新建一个html文件，引入编译后的js文件即可
*/
